package com.example.myapplication.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Update;
import androidx.room.Delete;
import androidx.room.Query;

import com.example.myapplication.model.FieldNotebookEntity;

import java.util.List;

@Dao
public interface FieldNotebookDao {
    @Insert
    void insert(FieldNotebookEntity entity);

    @Update
    void update(FieldNotebookEntity entity);

    @Delete
    void delete(FieldNotebookEntity entity);


    @Query("SELECT * FROM FieldNotebook WHERE name = :name")//
    FieldNotebookEntity findByName(String name);

    @Query("SELECT COUNT(*) FROM FieldNotebook WHERE name = :name")//
    int count(String name);


    @Query("SELECT * FROM FieldNotebook")//
    List<FieldNotebookEntity> getAllFieldNotebooks(); // 返回所有记录

    @Query("SELECT * FROM FieldNotebook WHERE isuploaded = 0")
    List<FieldNotebookEntity> getUnuploadedRecords();

    @Query("DELETE FROM FieldNotebook")//
    void deleteAll(); // 删除所有记录
}